package com.leoman.controller.api;

import com.leoman.core.ErrorType;
import com.leoman.core.bean.Result;
import com.leoman.entity.AppUser;
import com.leoman.entity.AppUserGain;
import com.leoman.entity.UserResume;
import com.leoman.entity.vo.AppUserGainPlusVo;
import com.leoman.entity.vo.VideoResumeVo;
import com.leoman.exception.*;
import com.leoman.service.AppUserGainService;
import com.leoman.service.AppUserService;
import com.leoman.utils.JsonUtil;
import com.leoman.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.multipart.MultipartRequest;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * 普通用户相关api
 * Created by 涂奕恒 on 2016/10/20 0018.
 */
@Controller
@RequestMapping(value = "api/appUser")
public class AppUserApi {

    @Autowired
    private AppUserService appUserService;

    @Autowired
    private AppUserGainService appUserGainService;

    /**
     * @api {post} /api/appUser/info 1、用户详情
     * @apiVersion 0.0.1
     * @apiName appUser.info
     * @apiGroup appUser
     *
     * @apiDescription 用户详情
     *
     * @apiParam   {Integer}  userId                    用户ID            (必填)
     *
     * @apiSuccess {Object}   userInfo
     * @apiSuccess {Integer}  userInfo.id               id
     * @apiSuccess {String}   userInfo.nickName         昵称
     * @apiSuccess {String}   userInfo.avatar           头像
     * @apiSuccess {String}   userInfo.mobile           手机
     * @apiSuccess {Integer}  userInfo.sex              性别
     * @apiSuccess {Integer}  userInfo.age              年龄
     * @apiSuccess {Integer}  userInfo.regionId         所在区域ID
     * @apiSuccess {Integer}  userInfo.regionInfo       所在区域名称
     * @apiSuccess {String}   userInfo.email            电子邮箱
     * @apiSuccess {Integer}  userInfo.money            账户余额
     * @apiSuccess {String}   userInfo.aliPayName       支付宝用户名
     * @apiSuccess {String}   userInfo.aliPayAccount    支付宝账号
     * @apiSuccess {String}   userInfo.createTime       注册时间
     * @apiSuccess {String}   userInfo.updateTime       修改时间
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {
     *          "userInfo": {
     *              "id": 14,
     *              "nickName": "老大",
     *              "avatar": "",
     *              "mobile": "13872116519",
     *              "sex": 0,
     *              "age": 0,
     *              "regionId": "",
     *              "email": "",
     *              "money": 0,
     *              "aliPayName": "",
     *              "aliPayAccount": "",
     *              "createTime": "1474600084564",
     *              "updateTime": "1474600084564"
     *          }
     *      }
     * }
     */
    @RequestMapping(value = "/info", method = RequestMethod.POST)
    public void info(HttpServletResponse response, Integer userId) {
        try {
            AppUser appUser = appUserService.iFindOneByInfo(userId);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successInfoApi(appUser, "userInfo"), "password", "type", "region", "openId"));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/modifyInfo 2、修改用户信息
     * @apiVersion 0.0.1
     * @apiName appUser.modifyInfo
     * @apiGroup appUser
     *
     * @apiDescription 修改用户信息
     *
     * @apiParam   {Integer}  userId                    用户ID          (必填)
     * @apiParam   {String}   nickName                  昵称
     * @apiParam   {Integer}  sex                       性别 0=男，1=女
     * @apiParam   {Integer}  age                       年龄
     * @apiParam   {Integer}  regionId                  所在区域ID
     * @apiParam   {String}   email                     电子邮箱
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     * }
     */
    @RequestMapping(value = "/modifyInfo", method = RequestMethod.POST)
    public void modifyInfo(HttpServletResponse response, Integer userId, String nickName, Integer sex, Integer age, Integer regionId, String email) {
        try {
            appUserService.iModifyAppUserInfo(userId, nickName, sex, age, regionId, email);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/modifyPassword 3、修改用户密码
     * @apiVersion 0.0.1
     * @apiName appUser.modifyPassword
     * @apiGroup appUser
     *
     * @apiDescription 修改用户密码
     *
     * @apiParam   {Integer}  userId                    用户ID          (必填)
     * @apiParam   {String}   oldPassword               旧密码          (必填)
     * @apiParam   {String}   newPassword               新密码          (必填)
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/modifyPassword", method = RequestMethod.POST)
    public void modifyPassword(HttpServletResponse response, Integer userId, String oldPassword, String newPassword) {
        try {
            appUserService.iModifyAppUserPassword(userId, oldPassword, newPassword);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (OldPasswordErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_OLD_PASSWORD_ERROR));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/modifyAliPayInfo 4、修改用户支付宝信息
     * @apiVersion 0.0.1
     * @apiName appUser.modifyAliPayInfo
     * @apiGroup appUser
     *
     * @apiDescription 修改用户支付宝信息
     *
     * @apiParam   {Integer}  userId                    用户ID          (必填)
     * @apiParam   {String}   aliPayName                支付宝姓名       (必填)
     * @apiParam   {String}   aliPayAccount             支付宝账户       (必填)
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/modifyAliPayInfo", method = RequestMethod.POST)
    public void modifyAliPayInfo(HttpServletResponse response, Integer userId, String aliPayName, String aliPayAccount) {
        try {
            appUserService.iModifyAppUserAliPayInfo(userId, aliPayName, aliPayAccount);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (AliPayInfoExistException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_A_PAY_INFO_EXIST));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/modifyAvatar 5、修改用户头像
     * @apiVersion 0.0.1
     * @apiName appUser.modifyAvatar
     * @apiGroup appUser
     *
     * @apiDescription 修改用户头像
     *
     * @apiParam   {Integer}  userId                    用户ID          (必填)
     * @apiParam   {Stream}   avatar                    头像文件        (必填)
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/modifyAvatar", method = RequestMethod.POST)
    public void modifyAvatar(HttpServletResponse response, Integer userId, MultipartRequest multipartRequest) {
        try {
            appUserService.iModifyAppUserAvatar(userId, multipartRequest);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/gainList 6、用户收支明细列表
     * @apiVersion 0.0.1
     * @apiName appUser.gainList
     * @apiGroup appUser
     *
     * @apiDescription 用户收支明细列表
     *
     * @apiParam   {Integer}   userId                         用户ID     （必填）
     * @apiParam   {Integer}   pageNum                        页码
     * @apiParam   {Integer}   pageSize                       每页显示条数（每次显示的月份数）
     *
     * @apiSuccess {Object}    list
     * @apiSuccess {Integer}   list.month                     年月
     * @apiSuccess {Integer}   list.gainList                  收支明细列表
     * @apiSuccess {Integer}   list.gainList.gainId           收支明细ID
     * @apiSuccess {String}    list.gainList.gainContent      收支明细内容
     * @apiSuccess {Integer}   list.gainList.gainMoney        收益金额
     * @apiSuccess {Integer}   list.gainList.gainCreateTime   收益获取时间
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status":0,
     *      "msg":"",
     *      "data":{
     *          "page": {
     *              "totalNum": 0,
     *              "totalPage": 0,
     *              "currentPage": 1
     *          },
     *          "list": [
     *              {
     *                  "month" : "2016-11",
     *                  "gainList" : [
     *                      {
     *                          "gainId" : 6,
     *                          "gainContent" : "观看视频---测试视频008",
     *                          "gainMoney" : 4,
     *                          "gainCreateTime" : 1479093217553
     *                      },
     *                      {
     *                          "gainId" : 7,
     *                          "gainContent" : "观看视频---测试视频008",
     *                          "gainMoney" : 4,
     *                          "gainCreateTime" : 1479093217553
     *                      }
     *                  ]
     *              }
     *          ]
     *      }
     * }
     */
    @RequestMapping(value = "/gainList", method = RequestMethod.POST)
    public void gainList(HttpServletResponse response, Integer userId, Integer pageNum, Integer pageSize) {
        try {
            Page<AppUserGain> page = appUserGainService.iPageByUserId(userId, pageNum, pageSize);
            Map<String, Object> dataMap = JsonUtil.fitting(page);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi(dataMap), "videoRecord", "appUser", "requestStatus", "id", "content", "money", "recordDate", "createTime"));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/applyMoney 7、用户申请提现
     * @apiVersion 0.0.1
     * @apiName appUser.applyMoney
     * @apiGroup appUser
     *
     * @apiDescription 用户申请提现
     *
     * @apiParam   {Integer}  userId                    用户ID          (必填)
     * @apiParam   {Double}   money                     提现金额        (必填)
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/applyMoney", method = RequestMethod.POST)
    public void applyMoney(HttpServletResponse response, Integer userId, Double money) {
        try {
            appUserService.iApplyMoney(userId, money);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (AliPayInfoNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_A_PAY_INFO_NOT_FIND));
        } catch (MoneyShortException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_MONEY_SHORT));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/resume/info 8、用户简历详情
     * @apiVersion 0.0.1
     * @apiName appUser.resumeInfo
     * @apiGroup appUser
     *
     * @apiDescription 用户简历详情
     *
     * @apiParam   {Integer}    userId                      用户ID            (必填)
     *
     * @apiSuccess {Object}     resumeInfo                  简历信息
     * @apiSuccess {String}     resumeInfo.userName         姓名
     * @apiSuccess {String}     resumeInfo.avatar           头像
     * @apiSuccess {Integer}    resumeInfo.age              年龄
     * @apiSuccess {String}     resumeInfo.mobile           电话
     * @apiSuccess {String}     resumeInfo.email            邮箱
     * @apiSuccess {Integer}    resumeInfo.regionId         所在地ID
     * @apiSuccess {Integer}    resumeInfo.regionInfo       所在地名称
     * @apiSuccess {Integer}    resumeInfo.cityId           户籍ID
     * @apiSuccess {Integer}    resumeInfo.cityInfo         户籍名称
     * @apiSuccess {String}     resumeInfo.nationInfo       民族
     * @apiSuccess {String}     resumeInfo.schoolName       毕业院校
     * @apiSuccess {String}     resumeInfo.educationInfo    学历
     * @apiSuccess {String}     resumeInfo.disciplineInfo   专业
     * @apiSuccess {String}     resumeInfo.situationInfo    在校情况
     * @apiSuccess {String}     resumeInfo.honorInfo        个人荣誉
     * @apiSuccess {String}     resumeInfo.skillInfo        工作经历
     * @apiSuccess {String}     resumeInfo.honorInfo        个人荣誉
     * @apiSuccess {Integer}    resumeInfo.createTime       创建时间
     * @apiSuccess {Integer}    resumeInfo.updateTime       修改时间
     * @apiSuccess {Object}     resumeInfo.imageList        证书列表
     * @apiSuccess {Integer}    resumeInfo.imageList.id     证书id
     * @apiSuccess {String}     resumeInfo.imageList.url    证书url
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {
     *          "resumeInfo": {
     *              "userName": "老大",
     *              "avatar": "http://www.qq.com",
     *              "age": "",
     *              "mobile": "13872116519",
     *              "email": 0,
     *              "regionId": 0,
     *              "regionInfo": "",
     *              "cityId": "",
     *              "cityInfo": "",
     *              "nationInfo": "",
     *              "schoolName": 0,
     *              "educationInfo": "",
     *              "disciplineInfo": "",
     *              "situationInfo": "",
     *              "honorInfo": "",
     *              "skillInfo": "",
     *              "createTime": "1474600084564",
     *              "updateTime": "1474600084564",
     *              "imageList": [
     *                  {
     *                      "id": 1,
     *                      "url": "http://ogbbsi37j.bkt.clouddn.com/Fj-I92vTFabzuRlyCtL8NAIUVZdC"
     *                  },
     *                  {
     *                      "id": 2,
     *                      "url": "http://ogbbsi37j.bkt.clouddn.com/Fj-I92vTFabzuRlyCtL8NAIUVZdC"
     *                  }
     *              ]
     *          }
     *      }
     * }
     */
    @RequestMapping(value = "/resume/info", method = RequestMethod.POST)
    public void resumeInfo(HttpServletResponse response, Integer userId) {
        try {
            UserResume userResume = appUserService.iFindOneByResumeInfo(userId);
            if (null == userResume) {
                WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successInfoApi(new UserResume(), "resumeInfo"), "region", "city", "appUser", "userResume"));
            } else {
                WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successInfoApi(userResume, "resumeInfo"), "region", "city", "appUser", "userResume"));
            }
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/resume/modifyInfo 9、用户修改简历信息
     * @apiVersion 0.0.1
     * @apiName appUser.modifyResumeInfo
     * @apiGroup appUser
     *
     * @apiDescription 用户修改简历信息
     *
     * @apiParam   {Integer}    userId                      用户ID            (必填)
     * @apiParam   {String}     userName                    姓名
     * @apiParam   {Integer}    age                         年龄
     * @apiParam   {String}     mobile                      电话
     * @apiParam   {String}     email                       邮箱
     * @apiParam   {Integer}    regionId                    所在地ID
     * @apiParam   {Integer}    cityId                      户籍ID
     * @apiParam   {String}     nationInfo                  民族
     * @apiParam   {String}     schoolName                  毕业院校
     * @apiParam   {String}     educationInfo               学历
     * @apiParam   {String}     disciplineInfo              专业
     * @apiParam   {String}     situationInfo               在校情况
     * @apiParam   {String}     honorInfo                   个人荣誉
     * @apiParam   {String}     skillInfo                   工作经历
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     * }
     */
    @RequestMapping(value = "/resume/modifyInfo", method = RequestMethod.POST)
    public void modifyResumeInfo(HttpServletResponse response,
                                 Integer userId,
                                 String userName,
                                 Integer age,
                                 String mobile,
                                 String email,
                                 Integer regionId,
                                 Integer cityId,
                                 String nationInfo,
                                 String schoolName,
                                 String educationInfo,
                                 String disciplineInfo,
                                 String situationInfo,
                                 String honorInfo,
                                 String skillInfo) {
        try {
            appUserService.iModifyResumeInfo(userId,
                    userName, age, mobile, email, regionId, cityId,
                    nationInfo, schoolName, educationInfo, disciplineInfo, situationInfo, honorInfo, skillInfo);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/sendResume 10、用户投递简历
     * @apiVersion 0.0.1
     * @apiName appUser.sendResume
     * @apiGroup appUser
     *
     * @apiDescription 用户投递简历
     *
     * @apiParam   {Integer}  userId                    用户ID          (必填)
     * @apiParam   {Integer}  videoId                   视频ID          (必填)
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/sendResume", method = RequestMethod.POST)
    public void sendResume(HttpServletResponse response, Integer userId, Integer videoId) {
        try {
            appUserService.iSendResume(userId, videoId);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (VideoNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_VIDEO_NOT_FIND));
        } catch (SendResumeExistException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_SEND_RESUME_EXIST));
        } catch (ResumeNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_RESUME_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/sendList 11、用户简历投放记录列表
     * @apiVersion 0.0.1
     * @apiName appUser.sendList
     * @apiGroup appUser
     *
     * @apiDescription 视频列表
     *
     * @apiParam   {Integer}   userId                     用户Id               （必填）
     * @apiParam   {Integer}   pageNum                    页码
     * @apiParam   {Integer}   pageSize                   每页显示条数
     *
     * @apiSuccess {Object}    list
     * @apiSuccess {Integer}   list.videoId               视频ID
     * @apiSuccess {String}    list.videoCover            视频封面
     * @apiSuccess {String}    list.videoName             视频名称
     * @apiSuccess {String}    list.typeName              视频分类名称
     * @apiSuccess {String}    list.videoDuration         视频时长
     * @apiSuccess {Integer}   list.price                 投放单价
     * @apiSuccess {Integer}   list.isGet                 是否获取奖励，0=否，1=是
     * @apiSuccess {String}    list.createTime            投递时间
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status":0,
     *      "msg":"",
     *      "data":{
     *          "page": {
     *              "totalNum": 0,
     *              "totalPage": 0,
     *              "currentPage": 1
     *          },
     *          "list": [
     *              {
     *                  "videoId" : 1,
     *                  "videoCover" : "http://www.qq.com",
     *                  "videoName" : "电子商务专员/互联网运营专员招聘",
     *                  "typeName" : "因特网",
     *                  "videoDuration" : "2分25秒"
     *                  "price" : 4
     *                  "isGet" : 1
     *                  "createTime" : "1474600084564"
     *              }
     *          ]
     *      }
     * }
     */
    @RequestMapping(value = "/sendList", method = RequestMethod.POST)
    public void sendList(HttpServletResponse response, Integer userId, Integer pageNum, Integer pageSize) {
        try {
            Page<VideoResumeVo> page = appUserService.iPageVideoResumeForApp(userId, pageNum, pageSize);
            Map<String, Object> dataMap = JsonUtil.fitting(page);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi(dataMap)));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        }
    }

    /**
     * @api {post} /api/appUser/modifyResumeImg 12、修改用户简历证书
     * @apiVersion 0.0.1
     * @apiName appUser.modifyResumeImg
     * @apiGroup appUser
     *
     * @apiDescription 修改用户简历证书
     *
     * @apiParam   {Integer}  userId                    用户ID                                  (必填)
     * @apiParam   {String}   deleteIds                 需要删除的证书id，中间用英文逗号隔开
     * @apiParam   {Integer}  imgNum                    新增证书数量
     * @apiParam   {Stream}   image                     新增证书文件
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/modifyResumeImg", method = RequestMethod.POST)
    public void modifyResumeImg(HttpServletResponse response, Integer userId, String deleteIds, Integer imgNum, MultipartRequest multipartRequest) {
        try {
            appUserService.iModifyResumeImg(userId, deleteIds, imgNum, multipartRequest);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        } catch (ResumeNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_RESUME_NOT_FIND));
        }
    }

    /**
     * @api {post} /api/appUser/modifyResumeAvatar 13、修改用户简历头像
     * @apiVersion 0.0.1
     * @apiName appUser.modifyResumeAvatar
     * @apiGroup appUser
     *
     * @apiDescription 修改用户简历头像
     *
     * @apiParam   {Integer}  userId                    用户ID         (必填)
     * @apiParam   {Stream}   avatar                    头像           (必填)
     *
     * @apiSuccessExample {json} Success-Response:
     * HTTP/1.1 200 OK
     * {
     *      "status": 0,
     *      "msg": "",
     *      "data": {}
     *      }
     * }
     */
    @RequestMapping(value = "/modifyResumeAvatar", method = RequestMethod.POST)
    public void modifyResumeAvatar(HttpServletResponse response, Integer userId, MultipartRequest multipartRequest) {
        try {
            appUserService.iModifyResumeAvatar(userId, multipartRequest);
            WebUtil.printApi(response, JsonUtil.obj2ApiJson(Result.successApi()));
        } catch (ParamErrorException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_NOT_PARAM));
        } catch (UserNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_NOT_FIND));
        } catch (UserSealStatusException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_USER_STATUS_DISABLED));
        } catch (ResumeNotFindException e) {
            WebUtil.printApi(response, Result.failureApi(ErrorType.ERROR_RESUME_NOT_FIND));
        }
    }
}
